<?php

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

class ActivityAlbum extends Model
{
    use SoftDelete;
    /**
     * 关联的数据表。
     *
     * @var string
     */
    protected $table = 'activity_album';
    protected $deleteTime = 'delete_at';
    protected $defaultSoftDelete = null;
    /**
     * 自动时间戳数据类型
     *
     * @var string
     */
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';
    /**
     * 属性默认值。
     *
     * @var array<int, string>
     */
    protected $attribute = [
        'src' => '',  // 图片地址
        'serial' => 1,  // 排序
        'status' => 1,  // 状态
        'activity_id' => 0,  // 活动
        'delete_at' => 0 // 删除时间
    ];
    /**
     * The attributes that are mass assignable.
     *
     * @var array<string>
     */
    protected $field = [
        'id', // ID
        'src',  // 图片地址
        'serial', // 序号
        'status', // 状态
        'activity_id',  // 活动
        'delete_at' // 删除时间
    ];
    /**
     * The attributes that should be cast.
     *
     * @var array<string>
     */
    protected $type = [
        'create_at' => 'timestamp:Y-m-d H:i:s',
        'update_at' => 'timestamp:Y-m-d H:i:s',
        'delete_at' => 'timestamp:Y-m-d H:i:s',
    ];
    public function searchActivityIdAttr($query, $value, $data)
    {
        $value > 0 && $query->where('activity_id', $value);
    }
}
